package com.zjj.lbw.ai.old.interviiew;

import org.springframework.ai.document.Document;
import org.springframework.ai.ollama.OllamaEmbeddingClient;
import org.springframework.ai.ollama.api.OllamaApi;

import java.util.List;

/**
 * 自定义向量模型客户端，文本向量化时候，只根据 “问题”做向量化
 */
public class ZjjOllamaEmbeddingClient extends OllamaEmbeddingClient {
    public ZjjOllamaEmbeddingClient(OllamaApi ollamaApi) {
        super(ollamaApi);
    }

    @Override
    public List<Double> embed(Document document) {

		// 单独对问题进行向量化
        String question = (String) document.getMetadata().get("question");

        return this.embed(question);
    }
}
